package com.devilvan.betrice.lol.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devilvan.betrice.lol.dto.LolBattleChampionDto;
import com.devilvan.betrice.lol.po.LolBattleChampionPo;
import com.devilvan.betrice.lol.service.LolBattleChampionService;
import com.devilvan.betrice.lol.mapper.LolBattleChampionMapper;
import com.devilvan.betrice.lol.repository.LolBattleChampionRepository;
import com.devilvan.betrice.util.UCopy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author Evad.Wu
* @Description LOL-对局英雄信息 业务逻辑类
* @date 2022-09-30
*/
@Service
public class LolBattleChampionServiceImpl extends ServiceImpl<LolBattleChampionMapper, LolBattleChampionPo> implements LolBattleChampionService {
    @Resource(name = "lolBattleChampionRepository")
    private LolBattleChampionRepository lolBattleChampionRepository;

    @Override
    public LolBattleChampionPo saveUpdate(LolBattleChampionDto lolBattleChampionDto) {
        LolBattleChampionPo lolBattleChampionPo = new LolBattleChampionPo();
        UCopy.fullCopy(lolBattleChampionDto, lolBattleChampionPo);
        return lolBattleChampionRepository.saveAndFlush(lolBattleChampionPo);
    }

    @Override
    public List<LolBattleChampionPo> saveUpdateBatch(List<LolBattleChampionDto> list) {
        List<LolBattleChampionPo> lolBattleChampionPoList = UCopy.fullCopyCollections(list, LolBattleChampionPo.class);
        return lolBattleChampionRepository.saveAllAndFlush(lolBattleChampionPoList);
    }
}
